﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iHub
{
    public partial class forgetStart : Form
    {
        public static forgetStart form1 = null;
        public String user = "";
        private AccountManager acct = new AccountManager();

        public forgetStart()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Start_Closing);
        }

        private void Start_Closing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                login n = new login();
                n.Show();
            }
        }

        public String getUsername()
        {
            return user;
        }

        private void loginButton_Click(object sender, EventArgs e)
        {
            user = username.Text;
            String question = acct.getQuestion(user);

            if (question != "")
            {
                form1 = this;
                this.Hide();

                forgetQuest view = new forgetQuest(question);
                view.ShowDialog();
            }
            else if (user == "")
            {
                DialogResult msg = MessageBox.Show("Please input your username.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                DialogResult msg = MessageBox.Show("The username does not exist in the database.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

        }

        private void forgetStart_Load(object sender, EventArgs e)
        {

        }

        private void back_Click(object sender, EventArgs e)
        {
            login n = new login();
            n.Show();
            this.Dispose();
        }
    }
}
